package com.zhangfb95.crosschain.sdk.infra.data.api.server;

import com.zhangfb95.crosschain.infra.model.Result;
import com.zhangfb95.crosschain.protocol.rpc.RequestHeaderConstants;
import com.zhangfb95.crosschain.sdk.infra.model.api.request.server.rpcchain.RpcGetBlockByNumberApiReq;
import com.zhangfb95.crosschain.sdk.infra.model.api.request.server.rpcchain.RpcGetHeightApiReq;
import com.zhangfb95.crosschain.sdk.infra.model.api.request.server.rpcchain.RpcGetTxByIdApiReq;
import com.zhangfb95.crosschain.sdk.infra.model.api.request.server.rpcchain.RpcQueryApiReq;
import com.zhangfb95.crosschain.sdk.infra.model.api.request.server.rpcchain.RpcSendApiReq;
import com.zhangfb95.crosschain.sdk.infra.model.api.response.server.rpcchain.RpcGetBlockByNumberApiRes;
import com.zhangfb95.crosschain.sdk.infra.model.api.response.server.rpcchain.RpcGetHeightApiRes;
import com.zhangfb95.crosschain.sdk.infra.model.api.response.server.rpcchain.RpcGetTxByIdApiRes;
import com.zhangfb95.crosschain.sdk.infra.model.api.response.server.rpcchain.RpcListChainNameApiRes;
import com.zhangfb95.crosschain.sdk.infra.model.api.response.server.rpcchain.RpcListChainPathApiRes;
import com.zhangfb95.crosschain.sdk.infra.model.api.response.server.rpcchain.RpcQueryApiRes;
import com.zhangfb95.crosschain.sdk.infra.model.api.response.server.rpcchain.RpcSendApiRes;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.service.annotation.HttpExchange;
import org.springframework.web.service.annotation.PostExchange;

/**
 * @author zhangfubing
 * @since 2023/10/19
 */
@HttpExchange("/rpc/chain")
public interface RpcChainApi {

    @PostExchange("/listChainName")
    Result<RpcListChainNameApiRes> listChainName(
            @RequestHeader(RequestHeaderConstants.USER_ID) String userId,
            @RequestHeader(RequestHeaderConstants.NONCE) String nonce,
            @RequestHeader(RequestHeaderConstants.TIMESTAMP) String timestamp,
            @RequestHeader(RequestHeaderConstants.AUTHORIZATION) String authorization);

    @PostExchange("/listChainPath")
    Result<RpcListChainPathApiRes> listChainPath(
            @RequestHeader(RequestHeaderConstants.USER_ID) String userId,
            @RequestHeader(RequestHeaderConstants.NONCE) String nonce,
            @RequestHeader(RequestHeaderConstants.TIMESTAMP) String timestamp,
            @RequestHeader(RequestHeaderConstants.AUTHORIZATION) String authorization);

    @PostExchange("/getHeight")
    Result<RpcGetHeightApiRes> getHeight(
            @RequestHeader(RequestHeaderConstants.USER_ID) String userId,
            @RequestHeader(RequestHeaderConstants.NONCE) String nonce,
            @RequestHeader(RequestHeaderConstants.TIMESTAMP) String timestamp,
            @RequestHeader(RequestHeaderConstants.AUTHORIZATION) String authorization,
            @RequestBody RpcGetHeightApiReq req);

    @PostExchange("/getBlockByNumber")
    Result<RpcGetBlockByNumberApiRes> getBlockByNumber(
            @RequestHeader(RequestHeaderConstants.USER_ID) String userId,
            @RequestHeader(RequestHeaderConstants.NONCE) String nonce,
            @RequestHeader(RequestHeaderConstants.TIMESTAMP) String timestamp,
            @RequestHeader(RequestHeaderConstants.AUTHORIZATION) String authorization,
            @RequestBody RpcGetBlockByNumberApiReq req);

    @PostExchange("/getTxById")
    Result<RpcGetTxByIdApiRes> getTxById(
            @RequestHeader(RequestHeaderConstants.USER_ID) String userId,
            @RequestHeader(RequestHeaderConstants.NONCE) String nonce,
            @RequestHeader(RequestHeaderConstants.TIMESTAMP) String timestamp,
            @RequestHeader(RequestHeaderConstants.AUTHORIZATION) String authorization,
            @RequestBody RpcGetTxByIdApiReq req);

    @PostExchange("/query")
    Result<RpcQueryApiRes> query(
            @RequestHeader(RequestHeaderConstants.USER_ID) String userId,
            @RequestHeader(RequestHeaderConstants.NONCE) String nonce,
            @RequestHeader(RequestHeaderConstants.TIMESTAMP) String timestamp,
            @RequestHeader(RequestHeaderConstants.AUTHORIZATION) String authorization,
            @RequestBody RpcQueryApiReq req);

    @PostExchange("/send")
    Result<RpcSendApiRes> send(
            @RequestHeader(RequestHeaderConstants.USER_ID) String userId,
            @RequestHeader(RequestHeaderConstants.NONCE) String nonce,
            @RequestHeader(RequestHeaderConstants.TIMESTAMP) String timestamp,
            @RequestHeader(RequestHeaderConstants.AUTHORIZATION) String authorization,
            @RequestBody RpcSendApiReq req);
}
